package org.dey.controller;

import com.github.pagehelper.PageInfo;
import org.dey.constant.MessageConstant;
import org.dey.entity.RequestData;
import org.dey.entity.Result;
import org.dey.pojo.Member;
import org.dey.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author deyran
 * @date 2022/3/31 16:44
 * @classname
 * @see
 */
@RestController
public class MemberController {

    @Autowired
    MemberService memberService;

    @PostMapping("/member")
    public Result<Member> memberAll(@RequestBody RequestData<Member> requestData) {
        Result<Member> result = new Result<>();
        PageInfo<Member> memberPageInfo = memberService.memberList(requestData);
        if (memberPageInfo.getTotal() >= 0) {
            result.setDataList(memberPageInfo);
            result.setMessage(MessageConstant.GET_MEMBER_RECORD_REPORT_SUCCESS);
            result.setFlag(true);
        } else {
            result.setFlag(false);
            result.setMessage(MessageConstant.GET_MEMBER_RECORD_REPORT_FAIL);
        }
        return result;
    }

}
